/*
 * Copyright 2009 Facebook
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *    http://www.apache.org/licenses/LICENSE-2.0

 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
*/

#import "ConnectAppDelegate.h"
#import "SessionViewController.h"
#import "FBConnect/FBConnect.h"
#import "KConnect/KConnect.h"

@implementation ConnectAppDelegate

@synthesize window;

- (void)dealloc {
  [window release];
  [controller release];
  [super dealloc];
}

///////////////////////////////////////////////////////////////////////////////////////////////////
// UIApplicationDelegate

- (void)applicationDidFinishLaunching:(UIApplication *)application {  
  
  [KCSession sessionWithApiKey:@"54ca6ecbc25e400694eeeae02d41ee0b"];
  [[KCSession session] useTesting:YES];

  
  KCAppAdded *msg0 = [[KCAppAdded alloc] initWithUID:@"2207927"];
  
  KCFeedPost *msg1 = [[KCFeedPost alloc] initWithPosterUID:@"32342"];
  [msg1 setPostType:KCPostTypeStory];
  [msg1 setTemplateID:234234];
  
  KCGoalCounts *msg2 = [[KCGoalCounts alloc] initWithUIDs:[NSArray arrayWithObjects:@"21545", nil]];
  [msg2 setGoalCount:1 value:23];
  [msg2 setGoalCount:3 value:42];
  [msg2 setGoalCount:4 value:64];
  
  KCPageRequest *msg3 = [[KCPageRequest alloc] initWithURL:@"http://www.google.com"];
  [msg3 setIP:@"192.168.0.1"];
  [msg3 setUID:@"156456"];
  
  
  
  KCSentMessage *msg4 = [[KCSentMessage alloc] 
                         initWithSenderUID:@"523223" 
                         recipientUIDs:[NSArray arrayWithObjects:@"23523", @"2352", nil] 
                         messageType:KCSentMessageTypeNotification];

  [msg4 setTemplateID:12421];
  [msg4 setSubType1:@"type1"];
  [msg4 setSubType2:@"type2"];
  
  KCUndirectedCommClick  *msg5 = [[KCUndirectedCommClick alloc] initWithUID:@"23523" type:@"ad"];
  KCUserInfo             *msg6 = [[KCUserInfo alloc] initWithUID:@"23523"];

  [msg6 setCountry:@"Canada"];
  [msg6 setBirthYear:@"1588"];
  [msg6 setGender:@"Bimale"];
  [msg6 setCity:@"Toronto St"];
  [msg6 setState:@"ON"];
  [msg6 setFriendCount:0];

  
  [[KCSession session] send:msg0];
  [[KCSession session] send:msg1];
  [[KCSession session] send:msg2];
  [[KCSession session] send:msg3];
  [[KCSession session] send:msg4];
  [[KCSession session] send:msg5];
  [[KCSession session] send:msg6];

  
  controller = [[SessionViewController alloc] init];
  controller.view.frame = CGRectMake(0, 20, 320, 460);

  [window addSubview:controller.view];
  [window makeKeyAndVisible];
}

@end
